package com.hqyj.bigdata_project.controller;

import com.hqyj.bigdata_project.entity.TopTenCatalogInfo;
import com.hqyj.bigdata_project.entity.TopTenVideoInfo;
import com.hqyj.bigdata_project.json.R;
import com.hqyj.bigdata_project.service.TopTenCatalogInfoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("catalog")
public class CatalogInfoController {

    @Resource
    private TopTenCatalogInfoService topTenCatalogInfoService;

    @GetMapping("/topTen")
    public R queryTopTenVideoInfoList(){
        List<TopTenCatalogInfo> topTenCatalogInfoList = null;
        try{
            topTenCatalogInfoList = topTenCatalogInfoService.queryTopTenCatalogInfoList();
            return R.success("查询播放量前十名的板块列表成功！",topTenCatalogInfoList);
        }catch (Exception ex){
            ex.printStackTrace();
            return R.error("程序出现异常！");
        }
    }

    @GetMapping("/topTwenty")
    public R queryTopTwentyVideoInfoList(){
        List<TopTenCatalogInfo> topTwentyCatalogInfoList = null;
        try{
            topTwentyCatalogInfoList = topTenCatalogInfoService.queryTopTwentyCatalogInfoList();
            return R.success("查询播放量前二十名的板块列表成功！",topTwentyCatalogInfoList);
        }catch (Exception ex){
            ex.printStackTrace();
            return R.error("程序出现异常！");
        }
    }
}
